<?php
/**
 * Created by PhpStorm.
 * User: 666
 * Date: 2020/4/16
 * Time: 16:18
 */

namespace App\Utility;

use EasySwoole\EasySwoole\Config as SystemConfig;
class ElasticSearch
{

    private static $obj ;

    static public function getInstance(){

        if(!self::$obj){

            $instance = SystemConfig::getInstance();
            $es = $instance->getConf('ES');
            $config = new \EasySwoole\ElasticSearch\Config([
                'host'          => $es['host'],
                'port'          => $es['port']
            ]);

            self::$obj = new \EasySwoole\ElasticSearch\ElasticSearch($config);
        }


        return  self::$obj;
    }

}